package pdfdemo

import (
	"errors"
	"fmt"
	"html/template"
	"io"
)

type Model interface {
}

type (
	AdModel struct {
		Model
	}

	DSPModel struct {
		Model
	}

	FrameworkModel struct {
	}
)

type PdfReporter interface {
	GetModel() (Model, error)
	BuildAndFlush(io.Writer) error
	SafeClose()
}

type AbstractPdfReporter struct {
	w io.Writer
}

func (a *AbstractPdfReporter) GetModel() (Model, error) {
	return nil, errors.New("unsupported")
}

func (a *AbstractPdfReporter) BuildAndFlush(writer io.Writer) error {
	a.w = writer

	model, err := a.GetModel()

	if err != nil {
		return err
	}

	htmlStr := render(model, template.HTML("abc"))
	fmt.Println(htmlStr)

	return nil
}

func render(model Model, html template.HTML) string {
	return ""
}

func (a *AbstractPdfReporter) SafeClose() {
}
